import { Schema, model } from 'mongoose';

const TCMKnowledgeSchema = new Schema({
    title: { type: String, required: true },
    content: { type: String, required: true },
    createdAt: { type: Date, default: Date.now },
});

const MedicinalCuisineSchema = new Schema({
    name: { type: String, required: true },
    ingredients: { type: [String], required: true },
    instructions: { type: String, required: true },
    createdAt: { type: Date, default: Date.now },
});

const WellnessKnowledgeSchema = new Schema({
    title: { type: String, required: true },
    content: { type: String, required: true },
    createdAt: { type: Date, default: Date.now },
});

const ProductSchema = new Schema({
    name: { type: String, required: true },
    description: { type: String, required: true },
    price: { type: Number, required: true },
    stock: { type: Number, required: true },
    createdAt: { type: Date, default: Date.now },
});

const OrderSchema = new Schema({
    userId: { type: String, required: true },
    products: [{ productId: String, quantity: Number }],
    totalAmount: { type: Number, required: true },
    orderDate: { type: Date, default: Date.now },
});

const ForumPostSchema = new Schema({
    title: { type: String, required: true },
    content: { type: String, required: true },
    authorId: { type: String, required: true },
    createdAt: { type: Date, default: Date.now },
    moderated: { type: Boolean, default: false },
});

const UserSchema = new Schema({
    username: { type: String, required: true, unique: true },
    password: { type: String, required: true },
    email: { type: String, required: true, unique: true },
    createdAt: { type: Date, default: Date.now },
});

export const TCMKnowledge = model('TCMKnowledge', TCMKnowledgeSchema);
export const MedicinalCuisine = model('MedicinalCuisine', MedicinalCuisineSchema);
export const WellnessKnowledge = model('WellnessKnowledge', WellnessKnowledgeSchema);
export const Product = model('Product', ProductSchema);
export const Order = model('Order', OrderSchema);
export const ForumPost = model('ForumPost', ForumPostSchema);
export const User = model('User', UserSchema);